// 封装token的获取/存储/清除函数
export const getToken = () => JSON.parse(localStorage.getItem('tokenInfo')) || ''

export const saveToken = (token) => localStorage.setItem('tokenInfo', JSON.stringify(token))

export const clearToken = () => localStorage.removeItem('tokenInfo')
// refreshtoken的获取/存储/清除
export const getRefreshToken = () => JSON.parse(localStorage.getItem('refreshToken')) || ''

export const saveRefreshToken = (token) => localStorage.setItem('refreshToken', JSON.stringify(token))

export const clearRefreshToken = () => localStorage.removeItem('refreshToken')

// 历史搜索记录
const historyKey = 'hm-mobile-70-history'

// 设置 history 历史记录
export const setHistory = (arr) => {
  localStorage.setItem(historyKey, JSON.stringify(arr))
}

// 获取 history 历史记录
export const getHistory = () => {
  return JSON.parse(localStorage.getItem(historyKey)) || []
}
